package com.zynn.service.module.es.controller;

import com.zynn.common.core.base.BaseController;
import com.zynn.common.pojo.result.Result;
import com.zynn.common.pojo.result.ResultUtil;
import com.zynn.service.module.es.service.InitUserFriendsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;

@Slf4j
@RestController
@Validated
@RequestMapping("sync/user")
public class SyncUserController extends BaseController {

    @Autowired
    private InitUserFriendsService initUserFriendsService;


    @RequestMapping(value = "/createOrUpdate", method = RequestMethod.POST)
    public Result syncUser(
            @RequestParam @Min(0) Long userId,
            String nickName,
            int sex,
            String headPic
    ) {
        initUserFriendsService.syncOneUser(userId, nickName, sex, headPic);
        return ResultUtil.success();
    }

}
